<template>
  <div class="indBox">
    <!--栏目1 新闻和通告-->
    <div class="lanmubox1">
      <!-- 校园新闻-->
      <div class="boxJrgz">
        <!-- 标头-->
        <div class="toubu">
          <router-link to="/news/list" class="more"><span>更多</span></router-link>
          <h3>
            <router-link to="/news/list">校园新闻</router-link>
          </h3>
        </div>
        <!-- 内容-->
        <div class="lancon">
          <!--焦点轮播图-->
          <!--          <div class="focusBox">
                      <div class="bd">
                        <ul>
                          <el-carousel height="229px" :autoplay="false">
                            <el-carousel-item v-for="(item,index) in newsListImg.slice(0,3)" :key="index">
                              <li style="display:list-item;">
                                <div class="pic">
                                  <a href="javascript:void(0)" @click="btnClick('news',item)">
                                    &lt;!&ndash;                  <img :src="item.img[0].url">&ndash;&gt;
                                    <img :src="changeUrl(item.img[0].fileName)">
                                  </a>
                                </div>
                                <div class="con">
                                  <div class="title" style="padding-left: 0px;text-align: center">
                                    <a href="javascript:void(0)" @click="btnClick('news',item)">{{
                                        vague('4', item.newsTitle)
                                      }}</a></div>
                                  <div class="bg"></div>
                                </div>
                              </li>
                            </el-carousel-item>
                          </el-carousel>
                        </ul>
                      </div>
                    </div>-->
          <div class="focusBox">
            <div class="bd">
              <ul>
                <el-carousel height="229px" :autoplay="false">
                  <el-carousel-item v-for="(item,index) in newsList.slice(0,3)" :key="index">
                    <li style="display:list-item;">
                      <div class="pic">
                        <a href="javascript:void(0)" @click="btnClick('news',item)">
<!--                          <img :src="item.url">-->
                          <el-image :lazy="true" :src="item.url"></el-image>
                        </a>
                      </div>
                      <div class="con">
                        <div class="title" style="padding-left: 0px;text-align: center">
                          <a href="javascript:void(0)" @click="btnClick('news',item)">{{
                              vague('4', item.newsTitle)
                            }}</a></div>
                        <div class="bg"></div>
                      </div>
                    </li>
                  </el-carousel-item>
                </el-carousel>
              </ul>
            </div>
          </div>
          <!--焦点列表-->
          <div class="xyxw">
            <ul class="infoList">
              <li class="t" v-for="(item,index) in newsList.slice(0,1)" :key="index">
                <div class="con" style="width: 100%">
                  <div class="title">
                    <a @click="btnClick('news',item)" class="tit" href="javascript:void(0)"
                       :title="'标题：'+item.newsTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                    >{{ vague('4', item.newsTitle) }}</a>
                  </div>
                  <div class="intro" v-html="item.newsContent"
                       style="word-break: break-all;text-overflow: ellipsis;-webkit-line-clamp: 4;overflow: hidden;-webkit-box-orient: vertical;display: -webkit-box;"
                  >
                  </div>
                  <!--                  <div class="intro" style="position: relative;">
                                      <span v-html="newsFirstContent"></span>
                                      <a style="padding-left: 250px; bottom: 0;position: absolute;"
                                         @click="btnClick('news',item)" class="more" href="javascript:void(0)"
                                      >[详细]</a>
                                      &lt;!&ndash;<a class="more" href="javascript:void(0)">[详细]</a>style="width:318px;height: 96px;-webkit-line-clamp: 4;overflow: hidden;-webkit-box-orient: vertical;display: -webkit-box;"&ndash;&gt;
                                    </div>-->
                </div>
              </li>
            </ul>
            <ul class="infoList">
              <li class="n" v-for="(item,index) in newsList.slice(1,4)" :key="index">
                <div class="title">
                  <span class="date">{{ parseTime(item.createTime, '{m}-{d}') }}</span>
                  <a @click="btnClick('news',item)" href="javascript:void(0)" class="tit"
                     :title="'标题：'+item.newsTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                  >{{ vague('1', item.newsTitle) }}
                  </a>
                </div>
              </li>
            </ul>
          </div>
        </div>
      </div>
      <!-- 通知公告 S -->
      <div class="boxXwgk">
        <dl>
          <dt class="hd">
            <router-link to="/notice/list" class="more"><span>更多</span></router-link>
            <h3>
              <router-link to="/notice/list">通知公告</router-link>
            </h3>
          </dt>
          <dd class="bd">
            <ul class="infoList infoListB">
              <li v-for="(item,index) in noticeList.slice(0,8)" :key="index">
                <span class="date">{{ parseTime(item.createTime, '{m}-{d}') }}</span>
                <a href="javascript:void(0)" @click="btnClick('notice',item)"
                   :title="'标题：'+item.noticeTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                >{{ vague('1', item.noticeTitle) }}</a>
              </li>
            </ul>
          </dd>
        </dl>
      </div>
    </div>

    <!--栏目2 政策法规、社联活动、社团风采-->
    <div class="lanmubox">
      <!-- 政策法规 -->
      <!--      <div class="lanmuth">
              <div class="hd">
                <router-link to="/policy/list" class="more"><span>更多>></span></router-link>
                <h3>
                  <router-link to="/policy/list"><span>政策法规</span></router-link>
                </h3>
              </div>
              <div class="bd">
                <ul>
                  <li class="t" v-for="(item,index) in policyList" :key="index">
                    <div class="pic">
                      <a @click="btnClick('policy',item)" href="javascript:;"
                         :title="'标题：'+item.policyTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                      >
                        <img :src="item.img[0].url">
                        <img :src="changeUrl(item.img[0].fileName)">
                      </a>
                    </div>
                    <div class="con">
                      <div class="title"></div>
                      <div class="intro">
                        <span v-html="item.policyContent"></span>
                        <a @click="btnClick('policy',item)" href="javascript:;">[详细]</a>
                      </div>
                    </div>
                  </li>

                </ul>

              </div>
            </div>-->
      <div class="lanmuth">
        <div class="hd">
          <router-link to="/policy/list" class="more"><span>更多>></span></router-link>
          <h3>
            <router-link to="/policy/list"><span>政策法规</span></router-link>
          </h3>
        </div>
        <div class="bd">
          <ul>
            <li class="n" v-for="(item,index) in policyList.slice(0,8)" :key="index">
              <div class="title">
                <span class="date">{{ parseTime(item.createTime, '{m}-{d}') }}</span>
                <a class="tit" href="javascript:void(0)"
                   @click="btnClick('policy',item)"
                   :title="'标题：'+item.policyTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                >{{ vague('7', item.policyTitle) }}</a></div>
            </li>
          </ul>
        </div>
      </div>
      <!-- 社团活动-->
      <div class="lanmutwo">
        <div class="hd">
          <router-link to="/activity/list" class="more"><span>更多>></span></router-link>
          <h3>
            <router-link to="/activity/list"><span>社联活动</span></router-link>
          </h3>
        </div>
        <div class="bd">
          <ul>
            <li class="t" v-for="(item,index) in activityList.slice(0,1)" :key="index">
              <div class="pic">
                <a @click="btnClick('activity',item)" :title="item.activityTitle" href="javascript:void(0)">
<!--                  <img :src="item.url">-->
                  <el-image :lazy="true" :src="item.url"></el-image>
                  <!--                  <img v-if="item.img.length<=0 || !item.img" src="@/assets/images/nopic.gif">
                                    <img v-else :src="changeUrl(item.img[0].fileName)">-->
                </a>
              </div>
              <div class="con">
                <div class="title">
                  <a class="tit" href="javascript:void(0)"
                     @click="btnClick('activity',item)"
                     :title="'标题：'+item.activityTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                  >{{ vague('5', item.activityTitle) }}</a></div>
                <div class="intro">活动时间：{{ item.createTime }}
                  <a @click="btnClick('activity',item)" class="more" href="javascript:void(0)">[详细]</a>
                </div>
              </div>
            </li>
          </ul>
          <ul>
            <li class="n" v-for="(item,index) in activityList.slice(1,5)" :key="index">
              <div class="title">
                <span class="date">{{ parseTime(item.createTime, '{m}-{d}') }}</span>
                <a class="tit" href="javascript:void(0)"
                   @click="btnClick('activity',item)"
                   :title="'标题：'+item.activityTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                >{{ vague('4', item.activityTitle) }}</a></div>
            </li>
          </ul>
        </div>

      </div>

      <!-- 换届选举 S -->
      <!--      <div class="lanmuone">
              <div class="hd">
                <router-link to="/pick/list" class="more"><span>更多>></span></router-link>
                <h3>
                  <router-link to="/pick/list">社联风采</router-link>
                </h3>
              </div>
              <div class="bd">
                <ul>
                  <li class="t" v-for="(item,index) in pickList.slice(0,1)" :key="index">
                    <div class="pic">
                      <a @click="btnClick('pick',item)" :title="item.pickTitle" href="javascript:void(0)">
                        &lt;!&ndash;                  <img v-if="item.img.length<=0 || !item.img" src="@/assets/images/nopic.gif">
                        &lt;!&ndash;                  <img v-else :src="item.img[0].url">&ndash;&gt;
                                          <img v-else :src="changeUrl(item.img[0].fileName)">&ndash;&gt;
                        <img :src="item.url">
                      </a>
                    </div>
                    <div class="con">
                      <div class="title">
                        <a class="tit" href="javascript:void(0)"
                           @click="btnClick('pick',item)"
                           :title="'标题：'+item.pickTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                        >{{ vague('5', item.pickTitle) }}</a></div>
                      <div class="intro">编写时间：{{ item.createTime }}
                        <a @click="btnClick('pick',item)" class="more" href="javascript:void(0)">[详细]</a>
                      </div>
                    </div>
                  </li>
                </ul>
                <ul>
                  <li class="n" v-for="(item,index) in pickList.slice(1,5)" :key="index">
                    <div class="title">
                      <span class="date">{{ parseTime(item.createTime, '{m}-{d}') }}</span>
                      <a class="tit" href="javascript:void(0)"
                         @click="btnClick('pick',item)"
                         :title="'标题：'+item.pickTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                      >{{ vague('4', item.pickTitle) }}</a></div>
                  </li>
                </ul>
              </div>
            </div>-->

      <div class="lanmuone">
        <div class="hd">
          <router-link to="/elect/list" class="more"><span>更多>></span></router-link>
          <h3>
            <router-link to="/elect/list">换届选举</router-link>
          </h3>
        </div>
        <div class="bd">
          <ul style="padding-top: 10px">
            <li class="n" v-for="(item,index) in electList.slice(0,8)" :key="index">
              <div class="title">
                <span class="date">{{ parseTime(item.createTime, '{m}-{d}') }}</span>
                <a class="tit" href="javascript:void(0)"
                   @click="btnClick('elect',item)"
                   :title="'标题：'+item.electTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                >{{ vague('4', item.electTitle) }}</a></div>
            </li>
          </ul>
        </div>
      </div>

    </div>

    <!--光荣榜-->
    <div class="indBox" id="xyfgBox">
      <div class="wHd">
        <h3>光荣之星</h3>
        <p>THE STAR OF GLORY</p>
      </div>
      <div class="wBd">
        <a class="prev" href="javascript:;" @click="zuohua('honour')"></a>
        <a class="next" href="javascript:;" @click="youhua('honour')"></a>
        <div class="tempWrap" style="overflow:hidden; position:relative; width:920px">
          <ul class="picList" :style="{'left':calleft + 'px', width: widthData + 'px'} "
              style="width: 6900px; position: relative; overflow: hidden; margin: 0px;"
              v-on:mouseover="stopmove()" v-on:mouseout="move()"
          >
            <li style="float: left; width: 190px;" class="first" v-for="(item,index) in honourList"
                :key="index"
            >
              <div class="pic" style="height: 202px">
                <a :title="'标题：'+item.honourTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                   href="javascript:void(0)"
                   @click="btnClick('honour',item)"
                >
<!--                  <img :src="item.url">-->
                  <el-image :lazy="true" :src="item.url"></el-image>
                  <!--                  <img :src="changeUrl(item.img[0].fileName)">-->
                </a>
              </div>
              <div class="title">
                <a :title="'标题：'+item.honourTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                   href="javascript:void(0)"
                   @click="btnClick('honour',item)"
                >{{ vague('6', item.honourTitle) }}</a>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>


    <!--企业赞助-->
    <div class="indBox" id="jyfwBox">
      <div class="wHd">
        <h3>企业赞助</h3>
        <p>CORPORATE SPONSORSHIP</p>
      </div>
      <dl class="wBd indTab" style="padding: 10px 0">
        <dd class="bd">
          <div class="column">
            <ul class="topicList" v-if="sponsorList.length<=0">
              <li class="noData" style="text-align: center;font-size: 16px">暂无内容</li>
            </ul>
            <ul class="topicList">
              <li :class="[(index%2!=0)?'evenT':'']" class="t" v-for="(item,index) in sponsorList.slice(0,4)" :key="index">
                <div class="pic">
                  <a :title="item.sponsorTitle" href="javascript:void(0)"
                     @click="btnClick('sponsor',item)"
                  >
<!--                    <img :src="item.url">-->
                    <el-image :lazy="true" :src="item.url"></el-image>
                  </a>
                </div>
                <div class="con">
                  <div class="title">
                    <span class="date">{{ parseTime(item.createTime, '{y}-{m}-{d}') }}</span>
                    <a class="tit" href="javascript:void(0)"
                       @click="btnClick('sponsor',item)"
                       :title="'标题：'+item.sponsorTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                    >{{ vague('1', item.sponsorTitle) }}
                    </a>
                  </div>
                  <div class="intro">
                    <div
                      style="word-break: break-all;text-overflow: ellipsis;-webkit-line-clamp: 3;overflow: hidden;-webkit-box-orient: vertical;display: -webkit-box;"
                      v-html="item.sponsorContent"
                    ></div>
                    <a class="more" href="javascript:void(0)">[详细]</a>
                  </div>
                </div>
              </li>
            </ul>
            <router-link to="/sponsor/list" class="nodeMore">查看更多&gt;&gt;</router-link>
          </div>
        </dd>
      </dl>
    </div>

    <!-- 社团简介 S -->
    <!--    <div class="indBox" id="xxjjBox">
          <div class="wHd">
            <h3>学校概况</h3>
            <p>SCHOOL PROFILE</p>
          </div>
          <div class="wBd">
             <span>
                <li class="t"><div class="pic"><a title="腾飞中的容职" href="/Item/2908.aspx" target="_blank"><img src="/UploadFiles/nopic.gif"></a></div><div class="con"><div class="title"></div><div class="intro">点击观看：容桂职业技术学校宣传片容桂职业技术学校位于佛山市顺德区容桂街道。顺德位于珠江三角洲中部，北临广州，毗邻港澳，容桂是珠江三角洲重要的工业制造基地、顺德经济重镇。容桂职业技术学校是顺德区区属全日制公办学校，广东省重点职业技术学校，国家职业技能鉴定所。学校创办于1976年，原名为容奇镇第二中学，19…<a class="more" href="/Item/2908.aspx" target="_blank">[详细]
                        </a></div></div></li>

    </span>
            <ul class="nodeList">  <li class="li1 first"><a title="学校简介" href="/Category_57/Index.aspx"><em class="icon"></em>学校简介</a></li>
              <li class="li2 even"><a title="质量年报" href="/Category_62/Index.aspx"><em class="icon"></em>质量年报</a></li>
              <li class="li3"><a title="学校章程" href="/Category_58/Index.aspx"><em class="icon"></em>学校章程</a></li>
              <li class="li4 even"><a title="组织机构" href="/Category_59/Index.aspx"><em class="icon"></em>组织机构</a></li>
              <li class="li5"><a title="校园新貌" href="/Category_26/Index.aspx"><em class="icon"></em>校园新貌</a></li>
              <li class="li6 even"><a title="校园文化" href="/Category_25/Index.aspx"><em class="icon"></em>校园文化</a></li>
              <li class="li7"><a title="现任领导" href="/Category_24/Index.aspx"><em class="icon"></em>现任领导</a></li>
              <li class="li8 last even"><a title="领导关怀" href="/Category_23/Index.aspx"><em class="icon"></em>领导关怀</a></li></ul>
          </div>
        </div>-->

    <div class="indBox" id="xyzjBox">
      <div class="wHd">
        <h3>社联风采</h3>
        <p>THE STYLE OF THE COUNCIL</p>
      </div>
      <div class="wBd">
        <a class="prev" href="javascript:;" @click="zuohua('pick')"></a>
        <a class="next" href="javascript:;" @click="youhua('pick')"></a>
        <div class="tempWrap" style="overflow:hidden; position:relative; width:920px">
          <ul class="picList"
              style="width: 6900px; position: relative; overflow: hidden; margin: 0px;"
              :style="{'left':calleft2 + 'px', width: widthData2 + 'px'} "
              v-on:mouseover="stopmove2()" v-on:mouseout="move2()"
          >
            <li class="first" v-for="(item,index) in pickList" :key="index">
              <div class="pic" style="height: 143px">
                <a :title="'标题：'+item.pickTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                   href="javascript:void(0)"
                   @click="btnClick('pick',item)"
                >
<!--                  <img :src="item.url">-->
                  <el-image :lazy="true" :src="item.url"></el-image>
                </a>
              </div>
              <div class="title">
                <a :title="'标题：'+item.pickTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                   href="javascript:void(0)"
                   @click="btnClick('pick',item)"
                >{{ vague('6', item.pickTitle) }}</a>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { listNews, updateNewsClick } from '@/api/news'
import { listNotice, updateNoticeClick } from '@/api/notice'
import { listActivity, updateActivityClick } from '@/api/activity'
import { listHonour, updateHonourClick } from '@/api/honour'
import { listPolicy, updateClickPolicy } from '@/api/policy'
import { listPick, updatePickClick } from '@/api/pick'
import { listSponsor, updateSponsorClick } from '@/api/sponsor'
import { listElect, updateElectClick } from '@/api/elect'

export default {
  name: 'Home',
  inject: ['reloadMain'],  //注入依赖
  components: {},
  data() {
    return {
      calleft: -2300,
      calleft2: -2300,
      theDirection: 'left',
      theDirection2: 'left',
      newsListImg: [], //带有图片的新闻数据
      newsList: [], // 新闻数据
      noticeList: [], // 公告表格数据
      activityList: [], // 活动表格数据
      honourList: [],
      policyList: [],
      pickList: [],
      sponsorList: [],
      electList: [],
      timer: null,
      timer2: null,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        status: '0'
      }
    }
  },
  computed: {
    widthData() {
      return 230 * Number(this.honourList.length) * 10
    },
    widthData2() {
      return 230 * Number(this.pickList.length) * 10
    }
  },
  created() {
    this.getNewsList()
    this.getNoticeList()
    this.getActivityList()
    this.getHonourList()
    this.getPolicyList()
    this.getPickList()
    this.getSponsorList()
    this.getElectList()
    this.move()
    this.move2()
  },
  methods: {
    /** 查询新闻列表 */
    getNewsList() {
      listNews(this.queryParams).then(response => {
        this.newsList = response.rows
        this.newsList.map(item => {
          item.url = this.getObjectKeys(item.newsContent)
        })

        /*this.newsList = response.rows
        this.newsList.map(item => {
          item.img = this.change(item.img)
          // item.img.url=this.changeUrl(item.img.fileName)
        })
        this.newsListImg = this.newsList.filter(item => {
          return item.img.length > 0
        })
        console.log(this.newsListImg)*/
      })
    },
    /** 查询公告列表 */
    getNoticeList() {
      listNotice(this.queryParams).then(response => {
        this.noticeList = response.rows
      })
    },
    /** 查询活动列表 */
    getActivityList() {
      listActivity(this.queryParams).then(response => {
        this.activityList = response.rows
        this.activityList.map(item => {
          item.url = this.getObjectKeys(item.activityContent)
        })
        /*this.activityList = response.rows.filter(item => {
          if (item.img && item.img !== '[]') {
            return item
          }
        })
        this.activityList.map(item => {
          item.img = JSON.parse(item.img)
        })*/
      })
    },
    /** 查询社联风采列表 */
    getPickList() {
      listPick(this.queryParams).then(response => {
        /*this.pickList = response.rows
        this.pickList.map(item => {
          // item.img = this.change(item.img)
          item.url=this.getObjectKeys(item.pickContent)
        })
        this.pickList=this.pickList.filter(item=>{
          return item.url!=null
        })*/
        this.pickList = response.rows
        this.pickList.map(item => {
          // item.img = this.change(item.img)
          item.url = this.getObjectKeys(item.pickContent)
        })
        let newsPickList = []
        for (let i = 0; i < 10; i++) {
          this.pickList.forEach((item, index) => {
            newsPickList.push(item)
          })
        }
        this.pickList = newsPickList
      })
    },
    /*查询光荣榜列表*/
    getHonourList() {
      listHonour(this.queryParams).then(response => {
        this.honourList = response.rows
        this.honourList.map(item => {
          // item.img = this.change(item.img)
          item.url = this.getObjectKeys(item.honourContent)
        })
        let newsHonourList = []
        for (let i = 0; i < 10; i++) {
          this.honourList.forEach((item, index) => {
            newsHonourList.push(item)
          })
        }
        this.honourList = newsHonourList
        /*this.honourList = response.rows.filter(item => {
          if (item.img && item.img !== '[]') {
            return item
          }
        })
        this.honourList.map(item => {
          item.img = JSON.parse(item.img)
        })
        let newsHonourList = []
        for (let i = 0; i <= 3; i++) {
          this.honourList.forEach((item, index) => {
            newsHonourList.push(item)
          })
        }
        this.honourList = newsHonourList*/
      })
    },
    /** 查询政策法规法规列表 */
    getPolicyList() {
      listPolicy(this.queryParams).then(response => {
        this.policyList = response.rows
        this.policyList.map(item => {
          item.img = this.change(item.img)
        })
        /*this.policyList = response.rows.filter(item => {
          if (item.img && item.img !== '[]') {
            return item
          }
        })
        this.policyList.map(item => {
          item.img = JSON.parse(item.img)
        })*/
      })
    },
    /** 查询赞助列表 */
    getSponsorList() {
      listSponsor(this.queryParams).then(res => {
        this.sponsorList = res.rows
        this.sponsorList.map(item => {
          // item.img = this.change(item.img)
          item.url = this.getObjectKeys(item.sponsorContent)
        })
      })
    },
    /** 查询换届选举 */
    getElectList() {
      listElect(this.queryParams).then(response => {
        this.electList = response.rows
      })
    },

    /* 确认点击按钮*/
    btnClick(btn, data) {
      if (btn == 'news') {
        // data.img = JSON.stringify(data.img)
        updateNewsClick(data)
        // this.getNewsList()
        this.jump('/news/list/edit', data.newsId)
      } else if (btn == 'notice') {
        updateNoticeClick(data)
        // this.getNoticeList()
        this.jump('/notice/list/edit', data.noticeId)
      } else if (btn == 'activity') {
        // data.img = JSON.stringify(data.img)
        updateActivityClick(data)
        this.jump('/activity/list/edit', data.activityId)
      } else if (btn == 'honour') {
        // data.img = JSON.stringify(data.img)
        updateHonourClick(data)
        this.jump('/honour/list/edit', data.honourId)
      } else if (btn == 'policy') {
        // data.img = JSON.stringify(data.img)
        updateClickPolicy(data)
        this.jump('/policy/list/edit', data.policyId)
      } else if (btn == 'pick') {
        // data.img = JSON.stringify(data.img)
        updatePickClick(data)
        this.jump('/pick/list/edit', data.pickId)
      } else if (btn == 'elect') {
        updateElectClick(data)
        this.jump('/elect/list/edit', data.electId)
      } else if (btn == 'sponsor') {
        updateSponsorClick(data)
        this.jump('/sponsor/list/edit', data.sponsorId)
      }
      this.reloadMain()
    },

    //路由跳转
    jump(path, id) {
      this.$router.push({
        path: path,
        query: {
          id: id
        }
      })
    },

    //图片自动移动
    move() {
      if (this.timer == null) {
        this.timer = setInterval(this.starmove, 50)
      }
    },
    move2() {
      if (this.timer2 == null) {
        this.timer2 = setInterval(this.starmove2, 50)
      }
    },
    //开始移动
    starmove() {
      if (this.theDirection == 'left') {
        this.calleft--
        if (this.calleft <= -4600) {
          this.calleft = -2300
        }
      } else {
        this.calleft++
        if (this.calleft >= 0) {
          this.calleft = -2300
        }
      }
    },
    starmove2() {
      if (this.theDirection2 == 'left') {
        this.calleft2--
        if (this.calleft2 <= -4600) {
          this.calleft2 = -2300
        }
      } else {
        this.calleft2++
        if (this.calleft2 >= 0) {
          this.calleft2 = -2300
        }
      }
    },
    //鼠标悬停时停止移动
    stopmove() {
      clearInterval(this.timer)
      this.timer = null
    },
    stopmove2() {
      clearInterval(this.timer2)
      this.timer2 = null
    },
    //点击按钮左移
    zuohua(e) {
      if (e == 'honour') {
        this.theDirection = 'left'
      } else if (e == 'pick') {
        this.theDirection2 = 'left'
      }

    },
    //点击按钮右移
    youhua(e) {
      if (e == 'honour') {
        this.theDirection = 'right'
      } else if (e == 'pick') {
        this.theDirection2 = 'right'
      }
    }
  },
  destroyed() {
    // 每次离开当前界面时，清除定时器
    clearInterval(this.timer)
    clearInterval(this.timer2)
    this.timer = null
    this.timer2 = null
  }
}
</script>

<style scoped>
/deep/ .el-carousel__indicator--horizontal {
  padding: 5px 4px;
}

/*/deep/.el-carousel__indicator.is-active button {
  background: #2387d5;
}
/deep/.el-carousel__button {
  width:13px; height:13px; line-height:13px; border-radius: 50%;opacity: 0.66;margin: 0 3px;
}*/
</style>
